<!DOCTYPE html>
<html lang="en">

<!-- Head tag -->
<head><meta name="generator" content="Hexo 3.9.0">

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!--Description-->
    

    <!--Author-->
    
        <meta name="author" content="ck">
    

    <!--Open Graph Title-->
    
        <meta property="og:title" content="CK&#39;s blogs">
    

    <!--Open Graph Description-->
    

    <!--Open Graph Site Name-->
    <meta property="og:site_name" content="CK&#39;s blogs">

    <!--Type page-->
    
        <meta property="og:type" content="website">
    

    <!--Page Cover-->
    

    <meta name="twitter:card" content="summary">
    

    <!-- Title -->
    
    <title>page - CK&#39;s blogs</title>

    <!-- Bootstrap Core CSS -->
    <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" integrity="sha384-y3tfxAZXuh4HwSYylfB+J125MxIs6mR5FOHamPBG064zB+AFeWH94NdvaCBm8qnd" crossorigin="anonymous">

    <!-- Custom Fonts -->
    <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" type="text/css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="//oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="//oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

    <!-- Gallery -->
    <link href="//cdnjs.cloudflare.com/ajax/libs/featherlight/1.3.5/featherlight.min.css" type="text/css" rel="stylesheet">

    <!-- Custom CSS -->
    <link rel="stylesheet" href="/blog/css/style.css">

    <!-- Google Analytics -->
    


</head>


<body>

<div class="bg-gradient"></div>
<div class="bg-pattern"></div>

<!-- Menu -->
<!--Menu Links and Overlay-->
<div class="menu-bg">
    <div class="menu-container">
        <ul>
            
            <li class="menu-item">
                <a href="/blog/">
                    Home
                </a>
            </li>
            
            <li class="menu-item">
                <a href="/blog/archives">
                    Archives
                </a>
            </li>
            
            <li class="menu-item">
                <a href="/blog/2019/09/04/本人简历/">
                    About
                </a>
            </li>
            
            <li class="menu-item">
                <a href="/blog/tags">
                    Tags
                </a>
            </li>
            
            <li class="menu-item">
                <a href="/blog/categories">
                    Categories
                </a>
            </li>
            
            <li class="menu-item">
                <a href="/blog/contact.html">
                    Contact
                </a>
            </li>
            
        </ul>
    </div>
</div>

<!--Hamburger Icon-->
<nav>
    <a href="#menu"></a>
</nav>

<div class="container">

    <!-- Main Content -->
    <div class="row">
    <div class="col-sm-12">

        <!--Title and Logo-->
        <header>
    <div class="logo">
        <a href="/blog/"><i class="logo-icon fa fa-cube" aria-hidden="true"></i></a>
        
            <h1 id="main-title" class="title">CK's blogs</h1>
        
    </div>
</header>

        <section class="main">
            
                
<div class="post">

    <div class="post-header index">
        <h1 class="title">
            <a href="/blog/2019/09/09/hexo-标签和分类使用错误问题/">
                hexo-标签和分类使用错误问题
            </a>
        </h1>
        <div class="post-info">
            
                <span class="date">2019-09-09</span>
            
            
            
        </div>
    </div>

    
        <div class="content">
            <p>我用hexo静态blog，用的是spfk主题.但是写文章时tags和categories都不起作用.我是按照说明写的：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">tags: 	</span><br><span class="line">    - tag1</span><br><span class="line">    - tag2</span><br></pre></td></tr></table></figure>

<p>添加标签</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo new page tags</span><br></pre></td></tr></table></figure>

<p>确认站点配置文件里有tag_dir: tags<br>确认主题配置文件里有tags: /tags<br>编辑站点的source/tags/index.md，添加</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">title: tags</span><br><span class="line">date: <span class="number">2015</span><span class="number">-10</span><span class="number">-20</span> <span class="number">06</span>:<span class="number">49</span>:<span class="number">50</span></span><br><span class="line">type: <span class="string">"tags"</span></span><br><span class="line">comments: false</span><br></pre></td></tr></table></figure>

<p>添加分类</p>
<p>hexo new page categories<br>确认站点配置文件里有category_dir: categories<br>确认主题配置文件里有categories: /categories<br>编辑站点的source/categories/index.md，添加</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">title: categories</span><br><span class="line">date: <span class="number">2015</span><span class="number">-10</span><span class="number">-20</span> <span class="number">06</span>:<span class="number">49</span>:<span class="number">50</span></span><br><span class="line">type: <span class="string">"categories"</span></span><br><span class="line">comments: false</span><br></pre></td></tr></table></figure>

<p>这样就OK了</p>

        </div>
    

</div>
            
                
<div class="post">

    <div class="post-header index">
        <h1 class="title">
            <a href="/blog/2019/09/09/来几张精美桌面壁纸/">
                来几张精美桌面壁纸
            </a>
        </h1>
        <div class="post-info">
            
                <span class="date">2019-09-09</span>
            
            
            
        </div>
    </div>

    
        <div class="content">
            <p>皮卡丘</p>
<img src="/blog/2019/09/09/来几张精美桌面壁纸/皮卡丘.jpg">

<p>刀妹</p>
<img src="/blog/2019/09/09/来几张精美桌面壁纸/36.jpg">

<p>舞女</p>
<img src="/blog/2019/09/09/来几张精美桌面壁纸/4511a337a92b20992b885992cd6fc4e2.jpg">

<p>知性美女</p>
<img src="/blog/2019/09/09/来几张精美桌面壁纸/154428-15097814681fc8.jpg">

<p>小丑女-哈莉</p>
<img src="/blog/2019/09/09/来几张精美桌面壁纸/28.png">

<p>焰灵姬</p>
<img src="/blog/2019/09/09/来几张精美桌面壁纸/25.png">

<p>夜幕</p>
<img src="/blog/2019/09/09/来几张精美桌面壁纸/13.png">

<p> 还不错吧？  诸君自取！！！</p>

        </div>
    

</div>
            
                
<div class="post">

    <div class="post-header index">
        <h1 class="title">
            <a href="/blog/2019/09/09/Django中的Auth模块/">
                Django中的Auth模块
            </a>
        </h1>
        <div class="post-info">
            
                <span class="date">2019-09-09</span>
            
            
            
        </div>
    </div>

    
        <div class="content">
            <h1 id="整理django中Auth模块"><a href="#整理django中Auth模块" class="headerlink" title="整理django中Auth模块"></a>整理django中Auth模块</h1><p><code>from django.contrib import auth</code></p>
<h2 id="一-设置"><a href="#一-设置" class="headerlink" title="一.设置"></a>一.设置</h2><p>默认Auth表单</p>
<p><code>auth</code>默认是使用自带的<code>user</code>表单</p>
<h3 id="自定义Auth表单"><a href="#自定义Auth表单" class="headerlink" title="自定义Auth表单"></a>自定义Auth表单</h3><p>一定要在<code>settings.py</code>中告诉<code>Django</code>，我现在使用我新定义的<code>UserInfo</code>表来做用户认证。写法如下：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"># 引用Django自带的User表，继承使用时需要设置</span><br><span class="line">AUTH_USER_MODEL = &quot;app名.UserInfo&quot;</span><br></pre></td></tr></table></figure>

<p>在<code>modles.py</code>创建表单模型可以对<code>AbstractUser</code>进行继承因为我们可以从源码中看出来auth自带的user表示继承<code>AbstractUser</code>类,所有我们可以可以同样继承然后对于他的内容进行自定义</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">from django.contrib.auth.models import AbstractUser</span><br><span class="line">class UserInfo(AbstractUser):</span><br><span class="line">    新增的内容</span><br><span class="line">    通过源码我们可以看出自带的几个内容</span><br></pre></td></tr></table></figure>

<p><code>AbstractUser</code>自带的字段</p>
<p><code>源码里的内容</code></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">username :账号</span><br><span class="line">first_name:姓</span><br><span class="line">last_name:名</span><br><span class="line">email:邮箱</span><br><span class="line">is_staff ： 用户是否拥有网站的管理权限.</span><br><span class="line">is_active： 是否允许用户登录, 设置为 False，可以在不删除用户的前提下禁止用户登录。</span><br><span class="line">date_joined:创建日期</span><br></pre></td></tr></table></figure>

<p>再看他的父级<code>AbstractBaseUser</code></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">password:密码</span><br><span class="line">last_login:最后一次登入时间</span><br><span class="line">is_active:是否允许用户登录, 设置为 False，可以在不删除用户的前提下禁止用户登录。</span><br></pre></td></tr></table></figure>

<p>再看他的另外的父级<code>PermissionsMixin</code></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">is_superuser:是否为超级账号也就管理员</span><br><span class="line">groups:分组</span><br><span class="line">user_permissions:用户权限</span><br></pre></td></tr></table></figure>

<p>我们可以再这基础上进行新增</p>
<h2 id="二-注册相关"><a href="#二-注册相关" class="headerlink" title="二.注册相关"></a>二.注册相关</h2><h3 id="创建普通用户"><a href="#创建普通用户" class="headerlink" title="创建普通用户"></a>创建普通用户</h3><p><code>create_user()</code></p>
<p>auth 提供的一个创建新用户的方法，需要提供必要参数（username、password）等。</p>
<p>用法：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">from django.contrib.auth.models import User</span><br><span class="line">user = User.objects.create_user（username=&apos;用户名&apos;,password=&apos;密码&apos;,email=&apos;邮箱&apos;,...）</span><br></pre></td></tr></table></figure>

<h3 id="创建超级用户"><a href="#创建超级用户" class="headerlink" title="创建超级用户"></a>创建超级用户</h3><p><code>create_superuser()</code></p>
<p>auth 提供的一个创建新的超级用户的方法，需要提供必要参数（username、password）等。</p>
<p>用法：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">from django.contrib.auth.models import User</span><br><span class="line">user = User.objects.create_superuser（username=&apos;用户名&apos;,password=&apos;密码&apos;,email=&apos;邮箱&apos;,...）</span><br></pre></td></tr></table></figure>

<h2 id="三-登入相关"><a href="#三-登入相关" class="headerlink" title="三.登入相关"></a>三.登入相关</h2><h3 id="验证登入"><a href="#验证登入" class="headerlink" title="验证登入"></a>验证登入</h3><p><code>authenticate()</code></p>
<p>提供了用户认证功能，即验证用户名以及密码是否正确，一般需要username 、password两个关键字参数。</p>
<p>如果认证成功（用户名和密码正确有效），便会返回一个 User 对象。</p>
<p>authenticate()会在该 User 对象上设置一个属性来标识后端已经认证了该用户，且该信息在后续的登录过程中是需要的。</p>
<p>用法：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">user = authenticate(username=&apos;usernamer&apos;,password=&apos;password&apos;)</span><br></pre></td></tr></table></figure>

<h3 id="将登入的对象存放在request中"><a href="#将登入的对象存放在request中" class="headerlink" title="将登入的对象存放在request中"></a>将登入的对象存放在request中</h3><p><code>login(HttpRequest, user)</code></p>
<p>该函数接受一个HttpRequest对象，以及一个经过认证的User对象。</p>
<p>该函数实现一个用户登录的功能。它本质上会在后端为该用户生成相关session数据。</p>
<p>用法：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">from django.contrib.auth import authenticate, login</span><br><span class="line">   </span><br><span class="line">def my_view(request):</span><br><span class="line">  username = request.POST[&apos;username&apos;]</span><br><span class="line">  password = request.POST[&apos;password&apos;]</span><br><span class="line">  user = authenticate(username=username, password=password)</span><br><span class="line">  if user is not None:</span><br><span class="line">    login(request, user)</span><br><span class="line">    # Redirect to a success page.</span><br><span class="line">    ...</span><br><span class="line">  else:</span><br><span class="line">    # Return an &apos;invalid login&apos; error message.</span><br><span class="line">    ...</span><br></pre></td></tr></table></figure>

<p>这样设置之后可以直接<code>request.user</code>点出其<code>账号相关信息</code></p>
<p><code>is_authenticated</code>为<code>True</code></p>
<h3 id="将登入的对象存放在request中去除"><a href="#将登入的对象存放在request中去除" class="headerlink" title="将登入的对象存放在request中去除"></a>将登入的对象存放在request中去除</h3><p><code>logout(request)</code></p>
<p>该函数接受一个HttpRequest对象，无返回值。</p>
<p>当调用该函数时，当前请求的session信息会全部清除。该用户即使没有登录，使用该函数也不会报错。</p>
<p>用法：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">from django.contrib.auth import logout</span><br><span class="line">   </span><br><span class="line">def logout_view(request):</span><br><span class="line">  logout(request)</span><br><span class="line">  # Redirect to a success page.</span><br></pre></td></tr></table></figure>

<p>这样设置之后可以直接<code>request.user</code>就为空</p>
<p><code>is_authenticated</code>为<code>False</code></p>
<h3 id="通过认证"><a href="#通过认证" class="headerlink" title="通过认证"></a>通过认证</h3><p><code>is_authenticated()</code></p>
<p>用来判断当前请求是否通过了认证。</p>
<p>用法:</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">def my_view(request):</span><br><span class="line">  if not request.user.is_authenticated():</span><br><span class="line">    return redirect(&apos;%s?next=%s&apos; % (settings.LOGIN_URL, request.path))</span><br></pre></td></tr></table></figure>

<p>页面中操作</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">&#123;% if request.user.is_authenticated %&#125;</span><br><span class="line">    如果里面有通过验证的user就为真没有就没否</span><br></pre></td></tr></table></figure>

<h2 id="四-登入装饰器"><a href="#四-登入装饰器" class="headerlink" title="四.登入装饰器"></a>四.登入装饰器</h2><p><code>login_requierd()</code></p>
<p>auth 给我们提供的一个装饰器工具，用来快捷的给某个视图添加登录校验。</p>
<p>用法：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">from django.contrib.auth.decorators import login_required</span><br><span class="line">      </span><br><span class="line">@login_required</span><br><span class="line">def my_view(request):</span><br><span class="line">  ...</span><br></pre></td></tr></table></figure>

<p>若用户没有登录，则会跳转到django默认的 登录URL ‘/accounts/login/ ‘ 并传递当前访问url的绝对路径 (登陆成功后，会重定向到该路径)。</p>
<p>如果需要自定义登录的URL，则需要在settings.py文件中通过LOGIN_URL进行修改。</p>
<p>示例：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">LOGIN_URL = &apos;/login/&apos;  # 这里配置成你项目登录页面的路由</span><br></pre></td></tr></table></figure>

<h2 id="五-密码相关"><a href="#五-密码相关" class="headerlink" title="五.密码相关"></a>五.密码相关</h2><h3 id="检验密码是否正确"><a href="#检验密码是否正确" class="headerlink" title="检验密码是否正确"></a>检验密码是否正确</h3><p><code>check_password(password)</code></p>
<p>auth 提供的一个检查密码是否正确的方法，需要提供当前请求用户的密码。</p>
<p>密码正确返回True，否则返回False。</p>
<p>用法：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">ok = user.check_password(&apos;密码&apos;)</span><br></pre></td></tr></table></figure>

<h3 id="修改密码"><a href="#修改密码" class="headerlink" title="修改密码"></a>修改密码</h3><p><code>set_password(password)</code></p>
<p>auth 提供的一个修改密码的方法，接收 要设置的新密码 作为参数。</p>
<p>注意：设置完一定要调用用户对象的save方法！！！</p>
<p>用法：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">user.set_password(password=&apos;&apos;)</span><br><span class="line">user.save()</span><br></pre></td></tr></table></figure>

<h2 id="六-注意"><a href="#六-注意" class="headerlink" title="六.注意"></a>六.注意</h2><p><code>上面的写的都是基于auth自带的user表达写的</code></p>
<p>导入</p>
<p><code>from django.contrib.auth.models import User</code></p>
<p>如果是自定义表单,请把<code>user换成你自定义的表单名称</code></p>

        </div>
    

</div>
            
                
<div class="post">

    <div class="post-header index">
        <h1 class="title">
            <a href="/blog/2019/09/09/Python参数传递引用机制/">
                Python参数传递引用机制
            </a>
        </h1>
        <div class="post-info">
            
                <span class="date">2019-09-09</span>
            
            
            
        </div>
    </div>

    
        <div class="content">
            <h1 id="Python的参数传递机制"><a href="#Python的参数传递机制" class="headerlink" title="Python的参数传递机制"></a>Python的参数传递机制</h1><p>Python使用按引用传递（pass-by-reference）将参数传递到函数中。如果你改变一个函数内的参数，会影响到函数的调用。这是Python的默认操作。不过，如果我们<strong>传递字面参数，比如字符串、数字或元组，它们是按值传递，这是因为它们是不可变的。</strong></p>
<p>python不允许程序员选择采用传值还是传引用。Python参数传递采用的肯定是“传对象引用”的方式。这种方式相当于传值和传引用的一种综合。如果函数收到的是一个可变对象（比如字典或者列表）的引用，就能修改对象的原始值－－相当于通过“传引用”来传递对象。<strong>如果函数收到的是一个不可变对象（比如数字、字符或者元组）的引用，就不能直接修改原始对象－－相当于通过“传值’来传递对象。</strong></p>

        </div>
    

</div>
            
                
<div class="post">

    <div class="post-header index">
        <h1 class="title">
            <a href="/blog/2019/09/08/hexo-图片无法显示/">
                hexo-图片无法显示
            </a>
        </h1>
        <div class="post-info">
            
                <span class="date">2019-09-08</span>
            
            
            
        </div>
    </div>

    
        <div class="content">
            <p>设置静态文件根目录<br>_config.yml中有个url和root参数<br>如果你部署的地址是<a href="http://yoursite.com/child，需要设置下面两个参数。" target="_blank" rel="noopener">http://yoursite.com/child，需要设置下面两个参数。</a></p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">url: <span class="string">'http://yoursite.com/child'</span> // 部署的域名</span><br><span class="line">root: <span class="string">'/child/'</span> // 部署的根目录</span><br></pre></td></tr></table></figure>

<p>设置资源文件夹<br>资源（Asset）代表 source 文件夹中除了文章以外的所有文件，例如图片、CSS、JS 文件等。比方说，如果你的Hexo项目中只有少量图片，那最简单的方法就是将它们放在 source/images 文件夹中。然后通过类似于 <img src="/images/image.jpg" alt> 的方法访问它们。</p>
<p>文章资源文件夹<br>对于那些想要更有规律地提供图片和其他资源以及想要将他们的资源分布在各个文章上的人来说，Hexo也提供了更组织化的方式来管理资源。这个稍微有些复杂但是管理资源非常方便的功能可以通过将 config.yml 文件中的 post_asset_folder 选项设为 true 来打开。</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">_config.yml</span><br><span class="line">post_asset_folder: true</span><br></pre></td></tr></table></figure>

<p>当资源文件管理功能打开后，Hexo将会在你每一次通过 hexo new [layout] <title> 命令创建新文章时自动创建一个文件夹。这个资源文件夹将会有与这个 markdown 文件一样的名字。将所有与你的文章有关的资源放在这个关联文件夹中之后，你可以通过相对路径来引用它们，这样你就得到了一个更简单而且方便得多的工作流。</title></p>
<p>相对路径引用的标签插件<br>通过常规的 markdown 语法和相对路径来引用图片和其它资源可能会导致它们在存档页或者主页上显示不正确。在Hexo 2时代，社区创建了很多插件来解决这个问题。但是，随着Hexo 3 的发布，许多新的标签插件被加入到了核心代码中。这使得你可以更简单地在文章中引用你的资源。</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">&#123;% asset_path slug %&#125;</span><br><span class="line">&#123;% asset_img slug [title] %&#125;   <span class="comment"># 图片</span></span><br><span class="line">&#123;% asset_link slug [title] %&#125;</span><br></pre></td></tr></table></figure>

<p>比如说：当你打开文章资源文件夹功能后，你把一个 example.jpg 图片放在了你的资源文件夹中，如果通过使用相对路径的常规 markdown 语法 <img src="/example.jpg" alt> ，它将 不会 出现在首页上。（但是它会在文章中按你期待的方式工作）</p>
<p>正确的引用图片方式是使用下列的标签插件而不是 markdown ：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">&#123;% asset_img example.jpg avatar %&#125;</span><br></pre></td></tr></table></figure>

<p>通过这种方式，图片将会同时出现在文章和主页以及归档页中。</p>
<p>通过</p>

        </div>
    

</div>
            
                
<div class="post">

    <div class="post-header index">
        <h1 class="title">
            <a href="/blog/2019/09/08/Pthon实现多人聊天室/">
                Pthon实现多人聊天室
            </a>
        </h1>
        <div class="post-info">
            
                <span class="date">2019-09-08</span>
            
            
            
        </div>
    </div>

    
        <div class="content">
            <h1 id="python实现网络多人聊天室"><a href="#python实现网络多人聊天室" class="headerlink" title="python实现网络多人聊天室"></a>python实现网络多人聊天室</h1><p><strong>文件结构：</strong></p>
<p>　　chatroom<br>　　├── client.py  # 客户端代码<br>　　├── language.py  # 语言文件<br>　　├── server.py  # 服务端代码<br>　　└── settings.py  # 设置文件</p>
<p>　　0 directories, 4 files</p>
<p><strong>使用模块：</strong></p>
<ul>
<li>os</li>
<li>sys</li>
<li>socket</li>
<li>select</li>
</ul>
<p><strong>思路：</strong></p>
<ul>
<li>settings.py，定义HOST、PORT、ADDR、buffersize、language、curuser等变量。</li>
<li>server.py，服务器代码，使用select模块select方法实现IO多路复用监听sys.stdin输入以及客户端连接，实现与客户端通信，将从客户端接收到的信息群发给每个客户端。</li>
<li>client.py，客户端代码，同样使用IO多路复用同时监听客户端接收信息以及sys.stdin输入信息，实现与服务端的通信，间接实现与其他客户端的群聊。</li>
<li>language.py，语言文件，支持中文以及英语。</li>
</ul>
<p><strong>代码：</strong></p>
<p><strong>*settings.py*</strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"># settings.py</span><br><span class="line"></span><br><span class="line">HOST = &apos;0.0.0.0&apos;      # 主机名</span><br><span class="line">PORT = 5555            # 端口号</span><br><span class="line">buffersize = 1024    # 缓冲大小</span><br><span class="line">ADDR = HOST, PORT    # 地址</span><br><span class="line"></span><br><span class="line">languages = [&apos;cn&apos;, &apos;en&apos;]      # &apos;cn&apos; -&gt; 中文</span><br><span class="line">language = &apos;cn&apos;                # &apos;en&apos; -&gt; 英文</span><br><span class="line"></span><br><span class="line">curuser = &apos;&apos;  # 当前用户</span><br></pre></td></tr></table></figure>

<p><strong>*language.py*</strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line"># language.py</span><br><span class="line"></span><br><span class="line">from settings import language</span><br><span class="line"></span><br><span class="line">if language == &apos;en&apos;:</span><br><span class="line">    administrator = &apos;Administrator&apos;</span><br><span class="line">    txt_administrator_close_chatroom = &apos;Chatroom closed by Administrator.&apos;</span><br><span class="line">    txt_uesr_enter_chatroom = &apos;entered the chatroom.&apos;</span><br><span class="line">    txt_user_quit_chatroom = &apos;quited the chatroom.&apos;</span><br><span class="line">    txt_username = &apos;username&gt; &apos;</span><br><span class="line">    txt_user_already_exists = &apos;Username already exists!&apos;</span><br><span class="line">    txt_connect_to = &apos;Connected to&apos;</span><br><span class="line">    txt_connect_from = &apos;Connected from&apos;</span><br><span class="line">elif language == &apos;cn&apos;:</span><br><span class="line">    administrator = &apos;管理员&apos;</span><br><span class="line">    txt_administrator_close_chatroom = &apos;管理员关闭了聊天室。&apos;</span><br><span class="line">    txt_uesr_enter_chatroom = &apos;进入了聊天室。&apos;</span><br><span class="line">    txt_user_quit_chatroom = &apos;退出了聊天室。&apos;</span><br><span class="line">    txt_username = &apos;用户名&gt; &apos;</span><br><span class="line">    txt_user_already_exists = &apos;用户名已存在。&apos;</span><br><span class="line">    txt_connect_to = &apos;连接到&apos;</span><br><span class="line">    txt_connect_from = &apos;连接从&apos;</span><br></pre></td></tr></table></figure>

<p><strong>*server.py*</strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br></pre></td><td class="code"><pre><span class="line"># server.py</span><br><span class="line"></span><br><span class="line"># 导入系统模块</span><br><span class="line">import os, sys</span><br><span class="line"># 导入网络编程（传输层）模块</span><br><span class="line">from socket import *</span><br><span class="line"># IO多路复用模块</span><br><span class="line">from select import select</span><br><span class="line"># 设置模块</span><br><span class="line">from settings import *</span><br><span class="line"># 语言模块</span><br><span class="line">from language import *</span><br><span class="line"></span><br><span class="line">def main():</span><br><span class="line">    &apos;main 主函数&apos;</span><br><span class="line">    server = socket(AF_INET, SOCK_STREAM)  # 建立TCP套接字</span><br><span class="line">    server.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)  # 设置端口可立即重用</span><br><span class="line">    server.bind(ADDR)  # 绑定地址</span><br><span class="line">    server.listen()  # 监听</span><br><span class="line"></span><br><span class="line">    # 接收函数</span><br><span class="line">    accept(server)</span><br><span class="line"></span><br><span class="line">def accept(server):</span><br><span class="line">    &apos;accept 服务器接受函数&apos;</span><br><span class="line"></span><br><span class="line">    # 使用select模块的select方法实现IO多路复用监听传输</span><br><span class="line">    rlist = [server, sys.stdin]</span><br><span class="line">    wlist = []</span><br><span class="line">    xlist = []</span><br><span class="line"></span><br><span class="line">    while True:</span><br><span class="line">        rs, ws, xs = select(rlist, wlist, xlist)</span><br><span class="line"></span><br><span class="line">        for r in rs:</span><br><span class="line">            if r is server:</span><br><span class="line">                # 服务器接受客户端连接</span><br><span class="line">                conn, addr = server.accept()</span><br><span class="line">                # 调用validate函数检查用户名</span><br><span class="line">                if validate(conn):</span><br><span class="line">                    # 将客户端套接字添加到rlist中以监听</span><br><span class="line">                    rlist.append(conn)</span><br><span class="line">                    # 如果用户名注册成功</span><br><span class="line">                    print(txt_connect_from, addr)</span><br><span class="line">                else:</span><br><span class="line">                    conn.close()</span><br><span class="line">            elif r is sys.stdin:</span><br><span class="line">                # 服务器向所有客户端发送系统（管理员）消息</span><br><span class="line">                data = sys.stdin.readline()</span><br><span class="line">                if data == &apos;\n&apos;:</span><br><span class="line">                    # 如果服务器输入回车，则退出</span><br><span class="line">                    for c in rlist[2:]:</span><br><span class="line">                        c.send(b&apos;\n&apos;)</span><br><span class="line">                        c.close()</span><br><span class="line">                    server.close()</span><br><span class="line">                    print(txt_administrator_close_chatroom)</span><br><span class="line">                    os._exit(0)</span><br><span class="line">                else:</span><br><span class="line">                    # 如果服务器输入正常语句，通知所有客户端</span><br><span class="line">                    data = administrator + &apos;: &apos; + data</span><br><span class="line">                    for c in rlist[2:]:</span><br><span class="line">                        c.send(data.encode())</span><br><span class="line">            else:</span><br><span class="line">                # 服务器接受客户端的消息并转发给所有客户端</span><br><span class="line">                data = r.recv(buffersize)</span><br><span class="line">                if not data:</span><br><span class="line">                    # 关闭客户端</span><br><span class="line">                    r.close()</span><br><span class="line">                    rlist.remove(r)</span><br><span class="line">                else:</span><br><span class="line">                    # 转发信息给其他客户端</span><br><span class="line">                    print(data.decode(), end=&apos;&apos;)</span><br><span class="line">                    for c in rlist[2:]:</span><br><span class="line">                        if c is not r:</span><br><span class="line">                            c.send(data)</span><br><span class="line"></span><br><span class="line">def validate(client):</span><br><span class="line">    &apos;检验用户名 validate username&apos;</span><br><span class="line">    name = client.recv(buffersize).decode()</span><br><span class="line">    # print(name.decode())</span><br><span class="line">    # print(users)</span><br><span class="line">    if name in users:</span><br><span class="line">        client.send(b&apos;Username already exists!&apos;)</span><br><span class="line">        return False</span><br><span class="line">    else:</span><br><span class="line">        users.append(name)</span><br><span class="line">        client.send(b&apos;Welcome!&apos;)</span><br><span class="line">        return True</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">if __name__ == &apos;__main__&apos;:</span><br><span class="line">    # 全局变量，管理用户信息</span><br><span class="line">    users = []</span><br><span class="line"></span><br><span class="line">    # 主函数</span><br><span class="line">    main()</span><br></pre></td></tr></table></figure>

<p><strong>*client.py*</strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br></pre></td><td class="code"><pre><span class="line"># client.py</span><br><span class="line"></span><br><span class="line"># 导入系统模块</span><br><span class="line">import os, sys</span><br><span class="line"># 导入网络编程（传输层）模块</span><br><span class="line">from socket import *</span><br><span class="line"># IO多路复用模块</span><br><span class="line">from select import select</span><br><span class="line"># 设置模块</span><br><span class="line">from settings import *</span><br><span class="line"># 语言模块</span><br><span class="line">from language import *</span><br><span class="line"></span><br><span class="line">def main():</span><br><span class="line">    &apos;main 主函数&apos;</span><br><span class="line">    client = socket(AF_INET, SOCK_STREAM)  # 建立TCP套接字</span><br><span class="line"></span><br><span class="line">    # 登录函数</span><br><span class="line">    if login(client):</span><br><span class="line">        # 连接函数</span><br><span class="line">        connect(client)</span><br><span class="line"></span><br><span class="line">def connect(client):</span><br><span class="line">    &apos;connect 客户端连接函数&apos;</span><br><span class="line"></span><br><span class="line">    # 使用select模块的select方法实现IO多路复用监听传输</span><br><span class="line">    rlist = [client, sys.stdin]</span><br><span class="line">    wlist = []</span><br><span class="line">    xlist = []</span><br><span class="line"></span><br><span class="line">    while True:</span><br><span class="line">        rs, ws, xs = select(rlist, wlist, xlist)</span><br><span class="line"></span><br><span class="line">        for r in rs:</span><br><span class="line">            if r is client:</span><br><span class="line">                # 接受服务器发来的消息</span><br><span class="line">                data = client.recv(buffersize)</span><br><span class="line">                if data.decode() == &apos;\n&apos;:</span><br><span class="line">                    # 如果消息为回车，聊天室关闭</span><br><span class="line">                    client.close()</span><br><span class="line">                    print(txt_administrator_close_chatroom)</span><br><span class="line">                    os._exit(0)</span><br><span class="line">                else:</span><br><span class="line">                    # 打印接收到的信息</span><br><span class="line">                    print(data.decode(), end=&apos;&apos;)</span><br><span class="line">            elif r is sys.stdin:</span><br><span class="line">                # 发送消息给服务器</span><br><span class="line">                data = sys.stdin.readline()</span><br><span class="line">                if data == &apos;\n&apos;:</span><br><span class="line">                    # 如果回车，发送退出消息，关闭客户端，退出聊天室</span><br><span class="line">                    data = curuser + &apos;: &apos; + txt_user_quit_chatroom + &apos;\n&apos;</span><br><span class="line">                    client.send(data.encode())</span><br><span class="line">                    client.close()</span><br><span class="line">                    os._exit(0)</span><br><span class="line">                else:</span><br><span class="line">                    # 发信息给服务器</span><br><span class="line">                    data = curuser + &apos;: &apos; + data</span><br><span class="line">                    client.send(data.encode())</span><br><span class="line"></span><br><span class="line">def login(client):</span><br><span class="line">    &apos;登录函数 login&apos;</span><br><span class="line">    # 使用全局变量管理用户</span><br><span class="line">    # 先让客户端输入姓名</span><br><span class="line">    global curuser</span><br><span class="line">    curuser = input(txt_username)</span><br><span class="line">    # 再连接到服务器，传送用户名以检验</span><br><span class="line">    client.connect(ADDR)  # 连接到服务器地址</span><br><span class="line">    print(txt_connect_to, ADDR)</span><br><span class="line">    client.send(curuser.encode())</span><br><span class="line">    data = client.recv(buffersize)</span><br><span class="line">    if data.decode() == &apos;Username already exists!&apos;:</span><br><span class="line">        # 如果用户名已经存在，要求重新输入</span><br><span class="line">        print(txt_user_already_exists)</span><br><span class="line">        return False</span><br><span class="line">    else:</span><br><span class="line">        # 发送信息给服务器，告知服务器用户进入聊天室</span><br><span class="line">        # -*- 因为监听传输的是sys.stdin.readline()，所以必须在最后添加换行符，以便清除阻塞 -*-</span><br><span class="line">        data = curuser + &apos;: &apos; + txt_uesr_enter_chatroom + &apos;\n&apos;</span><br><span class="line">        client.send(data.encode())</span><br><span class="line">        return True</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">if __name__ == &apos;__main__&apos;:</span><br><span class="line">    main()</span><br></pre></td></tr></table></figure>

<p><strong>运行截图：</strong></p>
 <img src="/blog/2019/09/08/Pthon实现多人聊天室/duo1.png">

<p><strong>总结：</strong></p>
<ul>
<li>在打代码之前，一定要先进行规划，大致写出项目的大概路线。</li>
<li>项目的实现要从最基本的地基开始，像这样一个网络间的多人聊天室的实现必须先从建立服务端和客户端开始，不能反而从表面入手。比如如果要做一个网络多人聊天室的图形化界面应用，绝对不可以先去写图形界面的实现，就算最后实现的图形界面多么好看，如果不能实现网络通信也白干。</li>
<li>对于项目中出错的点，应该多加注释，方便以后阅读，在网上查找到有益的知识，可以把网址复制下来，写进项目文档，方便以后不时之需。</li>
</ul>

        </div>
    

</div>
            
                
<div class="post">

    <div class="post-header index">
        <h1 class="title">
            <a href="/blog/2019/09/07/Mvc详解/">
                Mvc详解
            </a>
        </h1>
        <div class="post-info">
            
                <span class="date">2019-09-07</span>
            
            
            
        </div>
    </div>

    
        <div class="content">
            <h1 id="mvc-详解"><a href="#mvc-详解" class="headerlink" title="mvc 详解"></a><a href="https://www.cnblogs.com/liujie-php/p/9705117.html" target="_blank" rel="noopener">mvc 详解</a></h1><p><strong>MVC模式</strong>（Model–view–controller）是<a href="https://zh.wikipedia.org/wiki/%E8%BD%AF%E4%BB%B6%E5%B7%A5%E7%A8%8B" target="_blank" rel="noopener">软件工程</a>中的一种<a href="https://zh.wikipedia.org/wiki/%E8%BD%AF%E4%BB%B6%E6%9E%B6%E6%9E%84" target="_blank" rel="noopener">软件架构</a>模式，把软件系统分为三个基本部分：模型（Model）、视图（View）和控制器（Controller）。</p>
<p>MVC模式最早由<a href="https://zh.wikipedia.org/w/index.php?title=Trygve_Reenskaug&action=edit&redlink=1" target="_blank" rel="noopener">Trygve Reenskaug</a>在1978年提出，是<a href="https://zh.wikipedia.org/wiki/%E5%B8%95%E7%BE%85%E5%A5%A7%E5%A4%9A%E7%A0%94%E7%A9%B6%E4%B8%AD%E5%BF%83" target="_blank" rel="noopener">施乐帕罗奥多研究中心</a>（Xerox PARC）在20世纪80年代为程序语言<a href="https://zh.wikipedia.org/wiki/Smalltalk" target="_blank" rel="noopener">Smalltalk</a>发明的一种软件架构。<strong>MVC模式</strong>的目的是实现一种动态的程序设计，使后续对程序的修改和扩展简化，并且使程序某一部分的重复利用成为可能。除此之外，此模式通过对复杂度的简化，使程序结构更加直观。软件系统通过对自身基本部分分离的同时也赋予了各个基本部分应有的功能。专业人员可以通过自身的专长分组：</p>
<ul>
<li>控制器（Controller）- 负责转发请求，对请求进行处理。</li>
<li>视图（View） - 界面设计人员进行图形界面设计。</li>
<li>模型（Model） - 程序员编写程序应有的功能（实现算法等等）、数据库专家进行数据管理和数据库设计(可以实现具体的功能)。</li>
</ul>
<p>将应用程序划分为三种组件，模型 - 视图 - 控制器（MVC）设计定义它们之间的相互作用。<a href="https://zh.wikipedia.org/wiki/MVC#cite_note-posa-2" target="_blank" rel="noopener">
</a></p>
<ul>
<li><strong>模型（Model）</strong> 用于封装与应用程序的业务逻辑相关的数据以及对数据的处理方法。“ Model ”有对数据直接访问的权力，例如对数据库的访问。“Model”不依赖“View”和“Controller”，也就是说， Model 不关心它会被如何显示或是如何被操作。但是 Model 中数据的变化一般会通过一种刷新机制被公布。为了实现这种机制，那些用于监视此 Model 的 View 必须事先在此 Model 上注册，从而，View 可以了解在数据 Model 上发生的改变。（比如：<a href="https://zh.wikipedia.org/wiki/%E8%A7%82%E5%AF%9F%E8%80%85%E6%A8%A1%E5%BC%8F" target="_blank" rel="noopener">观察者模式</a>（<a href="https://zh.wikipedia.org/wiki/%E8%BD%AF%E4%BB%B6%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F" target="_blank" rel="noopener">软件设计模式</a>））</li>
<li><strong>视图（View）</strong>能够实现数据有目的的显示（理论上，这不是必需的）。在 View 中一般没有程序上的逻辑。为了实现 View 上的刷新功能，View 需要访问它监视的数据模型（Model），因此应该事先在被它监视的数据那里注册。</li>
<li><strong>控制器（Controller）</strong>起到不同层面间的组织作用，用于控制应用程序的流程。它处理事件并作出响应。“事件”包括用户的行为和数据 Model 上的改变。</li>
</ul>
<p><img src="https://img2018.cnblogs.com/blog/1222443/201809/1222443-20180926093157878-990137519.png" alt="img"></p>
<p>优点：</p>
<p><strong>1</strong> 多个 View 能共享一个 Model。</p>
<p><strong>2</strong> Controller 是自包含（self-contained）指高独立内聚的对象，与 Model 和 View 保持相对独立，所以可以方便的改变应用程序的数据层和业务规则。</p>
<p><strong>3</strong> Controller 提高了应用程序的灵活性和可配置性。</p>
<p>注解：</p>
<p><strong>1</strong> 如今，同一个Web应用程序会提供多种用户界面，例如用户希望既能够通过浏览器来收发<a href="https://zh.wikipedia.org/wiki/%E7%94%B5%E5%AD%90%E9%82%AE%E4%BB%B6" target="_blank" rel="noopener">电子邮件</a>，还希望通过手机来访问<a href="https://zh.wikipedia.org/wiki/%E7%94%B5%E5%AD%90%E9%82%AE%E7%AE%B1" target="_blank" rel="noopener">电子邮箱</a>，这就要求Web网站同时能提供<a href="https://zh.wikipedia.org/wiki/Internet" target="_blank" rel="noopener">Internet</a>界面和<a href="https://zh.wikipedia.org/wiki/WAP" target="_blank" rel="noopener">WAP</a>界面。在MVC设计模式中， Model 响应用户请求并返回响应数据，View 负责格式化数据并把它们呈现给用户，业务逻辑和表示层分离，同一个 Model 可以被不同的 View 重用，所以大大提高了代码的可重用性。</p>
<p><strong>2</strong> 例如，把数据库从<a href="https://zh.wikipedia.org/wiki/MySQL" target="_blank" rel="noopener">MySQL</a>移植到<a href="https://zh.wikipedia.org/wiki/Oracle" target="_blank" rel="noopener">Oracle</a>，或者把<a href="https://zh.wikipedia.org/wiki/RDBMS" target="_blank" rel="noopener">RDBMS</a>数据源改变成<a href="https://zh.wikipedia.org/wiki/LDAP" target="_blank" rel="noopener">LDAP</a>数据源，只需改变 Model 即可。一旦正确地实现了控制器，不管数据来自数据库还是<a href="https://zh.wikipedia.org/wiki/LDAP" target="_blank" rel="noopener">LDAP</a>服务器，View 都会正确地显示它们。由于MVC模式的三个模块相互独立，改变其中一个不会影响其他两个，所以依据这种设计思想能构造良好的少互扰性的构件。</p>
<p><strong>3</strong> Controller 可以用来连接不同的 Model 和 View 去完成用户的需求，也可以构造应用程序提供强有力的手段。给定一些可重用的 Model 、 View 和Controller 可以根据用户的需求选择适当的 Model 进行处理，然后选择适当的的 View 将处理结果显示给用户。</p>
<p>应用场景：典型的就是Django框架就是用的Mvc模式</p>

        </div>
    

</div>
            
                
<div class="post">

    <div class="post-header index">
        <h1 class="title">
            <a href="/blog/2019/09/06/面向对象程序设计的五大原则/">
                面向对象程序设计的五大原则
            </a>
        </h1>
        <div class="post-info">
            
                <span class="date">2019-09-06</span>
            
            
            
        </div>
    </div>

    
        <div class="content">
            <p>单一职责原则（SRP）<br>一个类应该仅有一个引起它变化的原因</p>
<p>开放封闭原则（OCP）<br>类模块是可拓展的，但是不可修改（对拓展开放，对更改封闭）</p>
<p>里氏替换原则（LSP）<br>子类必须能够替换它们的基类</p>
<p>依赖倒置原则（DIP）<br>高层模块不应该依赖于低层模块，二者都应该依赖于抽象</p>
<p>抽象不应该依赖于实现细节，实现细节应该依赖于抽象</p>
<p>接口隔离原则（ISP）<br>不应该强迫客户程序依赖于它们不用的方法</p>
<p>抽象工厂模式<br>应用于多系列相互依赖对象的构建方式，适合于对象集合稳定，但是对象风格变化多（系列多）。</p>

        </div>
    

</div>
            
                
<div class="post">

    <div class="post-header index">
        <h1 class="title">
            <a href="/blog/2019/09/06/面向对象四大特性/">
                面向对象四大特性
            </a>
        </h1>
        <div class="post-info">
            
                <span class="date">2019-09-06</span>
            
            
            
        </div>
    </div>

    
        <div class="content">
            <h1 id="面向对象四大特性："><a href="#面向对象四大特性：" class="headerlink" title="面向对象四大特性："></a>面向对象四大特性：</h1><h3 id="封装"><a href="#封装" class="headerlink" title="封装"></a>封装</h3><p>概念：封装指的是将隐匿某一些方法执行步骤，取而代之的是消息传递机制发送信息给他，减少代码量，复用性高</p>
<h3 id="继承"><a href="#继承" class="headerlink" title="继承"></a>继承</h3><p>概念：一个‘子类’，子类(派生类)对比父类(基类/超类)实现更加具体化，也就是说 继承可以使得子类具有父类的属性和方法或者重新定义、追加属性和方法等 </p>
<h3 id="多态"><a href="#多态" class="headerlink" title="多态"></a>多态</h3><p>概念： 由继承产生不同的类，其对象对于统一方法做出不同的效应，例如：根据打印机模型(基类)生成了两个不同的打印机，一个彩色(派生类)，一个黑白(派生类)，同是打印机打印出不同的效果，这就是多态</p>
<h4 id="多态存在的必要条件："><a href="#多态存在的必要条件：" class="headerlink" title="多态存在的必要条件："></a>多态存在的必要条件：</h4><ol>
<li>继承</li>
<li>重写</li>
<li>父类引用指向子类对象(派生类)</li>
</ol>
<h4 id="多态的优点"><a href="#多态的优点" class="headerlink" title="多态的优点"></a>多态的优点</h4><ol>
<li>消除类型之间的耦合关系</li>
<li>可替换性</li>
<li>可扩充性</li>
<li>接口性</li>
<li>灵活性</li>
<li>简化性</li>
</ol>
<h3 id="抽象"><a href="#抽象" class="headerlink" title="抽象"></a>抽象</h3><p>概念： 抽象 是简化复杂的现实问题的途径，它可以为具体问题找到最恰当的类定义，并且可以在最恰当的继承级别解释问题。举例说明，莱丝在大多数时候都被当作一条狗，但是如果想要让它做牧羊犬做的事，你完全可以调用牧羊犬的方法。如果狗这个类还有动物的父类，那么你完全可以视莱丝为一个动物 </p>

        </div>
    

</div>
            
                
<div class="post">

    <div class="post-header index">
        <h1 class="title">
            <a href="/blog/2019/09/05/redis集群-与python交互/">
                redis集群+与python交互
            </a>
        </h1>
        <div class="post-info">
            
                <span class="date">2019-09-05</span>
            
            
            
        </div>
    </div>

    
        <div class="content">
            <h1 id="redis集群"><a href="#redis集群" class="headerlink" title="redis集群"></a><code>redis</code>集群</h1><ul>
<li>概念：<ul>
<li>为什么要集群？<ul>
<li>虽然之前搞了主从部署，一主可以多从，但如果同时访问量(1000w)过大，主服务肯定就会挂掉，数据服务就挂掉了或者发生自然灾变</li>
<li>所以一些大公司都会部署很多服务器，如(华东地区、华北地区、西北地区、东北地区等都设立机房)</li>
</ul>
</li>
<li>集群概念：<ul>
<li>集群是一组相互独立的、通过高速网络互连的计算机，它们构成了一个组，并以单一系统的模式加以管理，一个客户与集群相互作用时，集群就像是一个独立的服务器，集群配置适用于提高可用性和可缩放性。</li>
<li>简单来说，就是一组通过网络连接的计算机，共同对外提交服务，像一个独立的服务器，目的就是提高处理性能</li>
</ul>
</li>
</ul>
</li>
</ul>
<h2 id="分类"><a href="#分类" class="headerlink" title="分类"></a>分类</h2><h3 id="软件层面"><a href="#软件层面" class="headerlink" title="软件层面"></a>软件层面</h3><ul>
<li>只有一台电脑，在这台电脑上启动了多个<code>redis</code>服务,服务之间组成集群，但是很容易坏掉，一个服务坏掉整个集群不能使用</li>
</ul>
<h3 id="硬件层面"><a href="#硬件层面" class="headerlink" title="硬件层面"></a>硬件层面</h3><ul>
<li>存在多台实体的电脑，每台电脑都启动了一个<code>redis</code>或者多个<code>redis</code>服务</li>
</ul>
<h3 id="在root用户下"><a href="#在root用户下" class="headerlink" title="在root用户下"></a>在root用户下</h3><h3 id="机器1"><a href="#机器1" class="headerlink" title="机器1"></a>机器1</h3><ul>
<li><p>建立一个<code>conf</code>的文件夹</p>
<ul>
<li><code>mkdir conf</code></li>
<li><code>cd conf</code></li>
</ul>
</li>
<li><p>在<code>conf</code>目录下创建 <code>7000.conf</code>文件</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">port <span class="number">7000</span></span><br><span class="line">bind 本地IP</span><br><span class="line">daemonize yes</span><br><span class="line">pidfile <span class="number">7000.</span>pid</span><br><span class="line">cluster-enabled yes</span><br><span class="line">cluster-config-file <span class="number">7000</span>_node.conf</span><br><span class="line">cluster-node-timeout <span class="number">15000</span></span><br><span class="line">appendonly yes</span><br></pre></td></tr></table></figure>
</li>
<li><p>在<code>conf</code>目录下创建<code>7001.conf</code> 文件</p>
</li>
</ul>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">6</span>port <span class="number">7001</span></span><br><span class="line">bind 本地IP</span><br><span class="line">daemonize yes</span><br><span class="line">pidfile <span class="number">7001.</span>pid</span><br><span class="line">cluster-enabled yes</span><br><span class="line">cluster-config-file <span class="number">7001</span>_node.conf</span><br><span class="line">cluster-node-timeout <span class="number">15000</span></span><br><span class="line">appendonly yes</span><br></pre></td></tr></table></figure>

<ul>
<li>在<code>conf</code>目录下创建 <code>7002.conf</code>文件</li>
</ul>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">port <span class="number">7002</span></span><br><span class="line">bind 本地IP</span><br><span class="line">daemonize yes</span><br><span class="line">pidfile <span class="number">7002.</span>pid</span><br><span class="line">cluster-enabled yes</span><br><span class="line">cluster-config-file <span class="number">7002</span>_node.conf</span><br><span class="line">cluster-node-timeout <span class="number">15000</span></span><br><span class="line">appendonly yes</span><br></pre></td></tr></table></figure>

<h4 id="总结："><a href="#总结：" class="headerlink" title="总结："></a>总结：</h4><ul>
<li>三个文件的配置区别在于<code>port、pidfile、cluster-config-file</code>三项</li>
</ul>
<h4 id="使用配置文件启动服务"><a href="#使用配置文件启动服务" class="headerlink" title="使用配置文件启动服务"></a>使用配置文件启动服务</h4><ul>
<li><code>redis-server 7000.conf</code></li>
<li><code>redis-server 7001.conf</code></li>
<li><code>redis-server 7002.conf</code></li>
</ul>
<h4 id="查看进程"><a href="#查看进程" class="headerlink" title="查看进程"></a>查看进程</h4><ul>
<li><code>ps aux | grep redis</code></li>
</ul>
<h3 id="机器2"><a href="#机器2" class="headerlink" title="机器2"></a>机器2</h3><ul>
<li><p>建立一个<code>conf</code>的文件夹</p>
<ul>
<li><code>mkdir conf</code></li>
<li><code>cd conf</code></li>
</ul>
</li>
<li><p>在<code>conf</code>目录下创建 <code>7003.conf</code>文件</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">port <span class="number">7003</span></span><br><span class="line">bind 本地IP</span><br><span class="line">daemonize yes</span><br><span class="line">pidfile <span class="number">7003.</span>pid</span><br><span class="line">cluster-enabled yes</span><br><span class="line">cluster-config-file <span class="number">7003</span>_node.conf</span><br><span class="line">cluster-node-timeout <span class="number">15000</span></span><br><span class="line">appendonly yes</span><br></pre></td></tr></table></figure>
</li>
<li><p>在<code>conf</code>目录下创建<code>7004.conf</code> 文件</p>
</li>
</ul>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">6</span>port <span class="number">7004</span></span><br><span class="line">bind 本地IP</span><br><span class="line">daemonize yes</span><br><span class="line">pidfile <span class="number">7004.</span>pid</span><br><span class="line">cluster-enabled yes</span><br><span class="line">cluster-config-file <span class="number">7004</span>_node.conf</span><br><span class="line">cluster-node-timeout <span class="number">15000</span></span><br><span class="line">appendonly yes</span><br></pre></td></tr></table></figure>

<ul>
<li>在<code>conf</code>目录下创建 <code>7005.conf</code>文件</li>
</ul>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">port <span class="number">7005</span></span><br><span class="line">bind 本地IP</span><br><span class="line">daemonize yes</span><br><span class="line">pidfile <span class="number">7005.</span>pid</span><br><span class="line">cluster-enabled yes</span><br><span class="line">cluster-config-file <span class="number">7005</span>_node.conf</span><br><span class="line">cluster-node-timeout <span class="number">15000</span></span><br><span class="line">appendonly yes</span><br></pre></td></tr></table></figure>

<h4 id="总结：-1"><a href="#总结：-1" class="headerlink" title="总结："></a>总结：</h4><ul>
<li>三个文件的配置区别在于<code>port、pidfile、cluster-config-file</code>三项</li>
</ul>
<h4 id="使用配置文件启动服务-1"><a href="#使用配置文件启动服务-1" class="headerlink" title="使用配置文件启动服务"></a>使用配置文件启动服务</h4><ul>
<li><code>redis-server 7003.conf</code></li>
<li><code>redis-server 7004.conf</code></li>
<li><code>redis-server 7005.conf</code></li>
</ul>
<h4 id="查看进程-1"><a href="#查看进程-1" class="headerlink" title="查看进程"></a>查看进程</h4><ul>
<li><code>ps aux | grep redis</code></li>
</ul>
<p>注：现在两台机器开启了6个<code>redis</code>服务</p>
<h3 id="创建集群"><a href="#创建集群" class="headerlink" title="创建集群"></a>创建集群</h3><ul>
<li><p><code>redis</code> 的安装包含了<code>redis-trib.rb</code>，用于创建集群</p>
</li>
<li><p>在这两台机器之一进行操作</p>
</li>
<li><p>将命令复制，可以在任意目录调用此命令 </p>
<ul>
<li><code>sudo cp /usr/share/doc/redis-tools/examples/redis-trib.rb /usr/local/bin/</code></li>
</ul>
</li>
<li><p>安装ruby环境，因为<code>redis-tirb.rb</code>是ruby开发的</p>
<ul>
<li><p><code>sudo apt-get install ruby</code></p>
</li>
<li><p>提示信息输入 y ， 然后回车继续安装</p>
</li>
</ul>
</li>
</ul>
<ul>
<li><h3 id="创建集群命令："><a href="#创建集群命令：" class="headerlink" title="创建集群命令："></a>创建集群命令：</h3><ul>
<li><h3 id="redis-trib-rb-create-replicas-1-所有启动redis服务ip加端口"><a href="#redis-trib-rb-create-replicas-1-所有启动redis服务ip加端口" class="headerlink" title="redis-trib.rb create --replicas 1 所有启动redis服务ip加端口"></a><code>redis-trib.rb create --replicas 1 所有启动redis服务ip加端口</code></h3></li>
</ul>
</li>
</ul>
<h4 id="报错处理"><a href="#报错处理" class="headerlink" title="报错处理"></a>报错处理</h4><ul>
<li>原因： ruby版本过低，因为天朝防火墙，所以需要设置 gem 的源<ul>
<li>查看只记得 gem 源是什么地址<ul>
<li><code>gem source -l</code>    如果是<a href="https://rubygems.org需要就更换" target="_blank" rel="noopener">https://rubygems.org需要就更换</a></li>
</ul>
</li>
<li>更换指令为<ul>
<li>gem sources –add <a href="https://gems.ruby-china.org/" target="_blank" rel="noopener">https://gems.ruby-china.org/</a> –remove <a href="https://rubygems.org/" target="_blank" rel="noopener">https://rubygems.org/</a></li>
</ul>
</li>
<li>通过 gem 安装<code>redis</code>的相关依赖<ul>
<li><code>sudo gem install redis</code></li>
</ul>
</li>
<li>然后重新执行创建指令</li>
<li>提示完成，集群搭建成功</li>
<li>可以看到主从关系</li>
</ul>
</li>
</ul>
<h3 id="数据验证-c-连接集群"><a href="#数据验证-c-连接集群" class="headerlink" title="数据验证 -c 连接集群"></a>数据验证 -c 连接集群</h3><ul>
<li><code>redis-cli -n 主机IP -c -p 要链接的redis端口</code></li>
</ul>
<p>Ps：连接完成后，就可以正常使用了</p>
<p>它里边有一个槽的概念，存储数据会自动 匹配数据要存放的服务器。自动跳转，每个集群至少有三个主服务（节点）</p>
<h1 id="python-和-redis-集群交互"><a href="#python-和-redis-集群交互" class="headerlink" title="python 和 redis 集群交互"></a><code>python</code> 和 <code>redis</code> 集群交互</h1><figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">例：</span><br><span class="line"><span class="keyword">from</span> rediscluster <span class="keyword">import</span> StrictRedisCluster</span><br><span class="line"><span class="keyword">if</span> __name__ == <span class="string">'__main__'</span>:</span><br><span class="line">    <span class="keyword">try</span>:</span><br><span class="line">        <span class="comment"># 构建所有节点，redis会使用CRC16算法，将键和值写到某个节点上</span></span><br><span class="line">        startup_nodes=[</span><br><span class="line">            &#123;<span class="string">'host'</span>:<span class="string">'redis集群服务的主服务ip'</span>,<span class="string">'port'</span>:<span class="string">'对应端口'</span>&#125;,</span><br><span class="line">            &#123;<span class="string">'host'</span>:<span class="string">'redis集群服务的主服务ip'</span>,<span class="string">'port'</span>:<span class="string">'对应端口'</span>&#125;,</span><br><span class="line">            &#123;<span class="string">'host'</span>:<span class="string">'redis集群服务的主服务ip'</span>,<span class="string">'port'</span>:<span class="string">'对应端口'</span>&#125;,    <span class="comment"># 只写主从的主服务</span></span><br><span class="line">        ]</span><br><span class="line">        <span class="comment"># 构建StrictRedisCluster对象</span></span><br><span class="line">        src = StrictRedisCluster(startup_nodes=startup_nodes,decode_responses=<span class="literal">True</span>)</span><br><span class="line">        <span class="comment"># 设置键为 name 值为 chenkai 的数据</span></span><br><span class="line">        result= src.set(<span class="string">'name'</span>,<span class="string">'chenkai'</span>)</span><br><span class="line">        print(result)</span><br><span class="line">        name = src.get(<span class="string">'name'</span>)</span><br><span class="line">    	print(name)</span><br><span class="line">	<span class="keyword">except</span> Exception <span class="keyword">as</span> e:</span><br><span class="line">        print(e)</span><br></pre></td></tr></table></figure>

<h2 id="总结：-2"><a href="#总结：-2" class="headerlink" title="总结："></a>总结：</h2><p>集群就是一组通过网络连接的计算机，共同对外提供服务，想一个独立的服务器！</p>

        </div>
    

</div>
            
        </section>
    </div>
</div>



    <div class="row">
        <div class="col-sm-12">
            <div class="wrap-pagination">
                <a class="" href="/blog/">
                    <i class="fa fa-chevron-left" aria-hidden="true"></i>
                </a>
                <a class="" href="/blog/page/3/">
                    <i class="fa fa-chevron-right" aria-hidden="true"></i>
                </a>
            </div>
        </div>
    </div>




</div>

<!-- Footer -->
<div class="push"></div>

<footer class="footer-content">
    <div class="container">
        <div class="row">
            <div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 footer-about">
                <h2>About</h2>
                <p>
                    This theme was developed by <a href="https://github.com/klugjo">Jonathan Klughertz</a>. The source code is available on Github. Create Websites. Make Magic.
                </p>
            </div>
            
    <div class="col-xs-6 col-sm-6 col-md-3 col-lg-3 recent-posts">
        <h2>Recent Posts</h2>
        <ul>
            
            <li>
                <a class="footer-post" href="/blog/2019/10/25/tars框架环境基础搭建/">tars框架环境基础搭建</a>
            </li>
            
            <li>
                <a class="footer-post" href="/blog/2019/10/20/认识tars框架/">认识tars框架</a>
            </li>
            
            <li>
                <a class="footer-post" href="/blog/2019/10/05/redis数据迁移备份与恢复/">redis数据迁移备份与恢复</a>
            </li>
            
            <li>
                <a class="footer-post" href="/blog/2019/09/21/负载均衡的5种策略/">负载均衡的5种策略</a>
            </li>
            
        </ul>
    </div>



            
        </div>
        <div class="row">
            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                <ul class="list-inline footer-social-icons">
                    
                    <li class="list-inline-item">
                        <a href="https://github.com/klugjo/hexo-theme-alpha-dust">
                            <span class="footer-icon-container">
                                <i class="fa fa-github"></i>
                            </span>
                        </a>
                    </li>
                    
                    
                    <li class="list-inline-item">
                        <a href="https://twitter.com/?lang=en">
                            <span class="footer-icon-container">
                                <i class="fa fa-twitter"></i>
                            </span>
                        </a>
                    </li>
                    
                    
                    <li class="list-inline-item">
                        <a href="https://www.facebook.com/">
                            <span class="footer-icon-container">
                                <i class="fa fa-facebook"></i>
                            </span>
                        </a>
                    </li>
                    
                    
                    <li class="list-inline-item">
                        <a href="https://www.instagram.com/">
                            <span class="footer-icon-container">
                                <i class="fa fa-instagram"></i>
                            </span>
                        </a>
                    </li>
                    
                    
                    <li class="list-inline-item">
                        <a href="https://dribbble.com/">
                            <span class="footer-icon-container">
                                <i class="fa fa-dribbble"></i>
                            </span>
                        </a>
                    </li>
                    
                    
                    <li class="list-inline-item">
                        <a href="https://plus.google.com/">
                            <span class="footer-icon-container">
                                <i class="fa fa-google-plus"></i>
                            </span>
                        </a>
                    </li>
                    
                    
                    <li class="list-inline-item">
                        <a href="https://www.behance.net/">
                            <span class="footer-icon-container">
                                <i class="fa fa-behance"></i>
                            </span>
                        </a>
                    </li>
                    
                    
                    <li class="list-inline-item">
                        <a href="https://500px.com/">
                            <span class="footer-icon-container">
                                <i class="fa fa-500px"></i>
                            </span>
                        </a>
                    </li>
                    
                    
                    <li class="list-inline-item">
                        <a href="mailto:test@example.com">
                            <span class="footer-icon-container">
                                <i class="fa fa-envelope-o"></i>
                            </span>
                        </a>
                    </li>
                    
                    
                    <li class="list-inline-item">
                        <a href="\#">
                            <span class="footer-icon-container">
                                <i class="fa fa-rss"></i>
                            </span>
                        </a>
                    </li>
                    
                </ul>
            </div>
        </div>
        <div class="row">
            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                <div class="footer-copyright">
                    @Untitled. All right reserved | Design & Hexo <a href="http://www.codeblocq.com/">Jonathan Klughertz</a>
                </div>
            </div>
        </div>
    </div>
</footer>

<!-- After footer scripts -->

<!-- jQuery -->
<script src="//code.jquery.com/jquery-2.1.4.min.js"></script>

<!-- Tween Max -->
<script src="//cdnjs.cloudflare.com/ajax/libs/gsap/1.18.5/TweenMax.min.js"></script>

<!-- Gallery -->
<script src="//cdnjs.cloudflare.com/ajax/libs/featherlight/1.3.5/featherlight.min.js" type="text/javascript" charset="utf-8"></script>

<!-- Custom JavaScript -->
<script src="/blog/js/main.js"></script>

<!-- Disqus Comments -->



</body>

</html>